﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>修改分类</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="/style/admin/style/adminStyle.css" rel="stylesheet" type="text/css" />
        <script src="/style/admin/js/jquery.js"></script>
    </head>
    <body>
        <div class="wrap">
            <div class="page-title">
                <span class="modular fl"><i></i><em>修改分类</em></span>
            </div>

            <table class="list-style">
                <form action="" id="Category_Add" onsubmit="return false" >
                    <tr>
                        <td style="text-align:right;width:15%;">分类名称：</td>
                        <td>
                            <input type="text" name="name" value="{{$data->name}}" class="textBox"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;width:10%;">上级分类：</td>
                        <td>
                            <select class="textBox" name="pid"> 
                                @if(!empty($info))
                                <option value="{{$info->path}}{{$info->id}}">{{$info->name}}</option>
                                @endif
                                @foreach($all as $value)
                                <option value="{{$value->path}}{{$value->id}}">{{$value->name}}</option>
                                @endforeach
                            </select> 
                        </td>
                        <input type="hidden" name="path" value=""/>
                        <input type="hidden" name="id" value="{{$data->id}}"/>
                    </tr>
                    <tr>
                        <td style="text-align:right;">数量单位：</td>
                        <td>
                            <input type="text" name="unit" value="{{$data->unit}}" class="textBox length-short"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">排序：</td>
                        <td>
                            <input type="text" name="sort" value="{{$data->sort}}" class="textBox length-short"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">是否显示：</td>
                        <td>
                            @if($data->is_show==1)
                            <input type="radio" name="is_show" value="1" checked id="yes"/>
                            <label for="yes">是</label>
                            <input type="radio" name="is_show" value="0" id="no"/>
                            <label for="no">否</label>
                            @else
                            <input type="radio" name="is_show" value="1"  id="yes"/>
                            <label for="yes">是</label>
                            <input type="radio" name="is_show" value="0" checked id="no"/>
                            <label for="no">否</label>
                            @endif
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">是否楼层：</td>
                        <td>
                            @if($data->is_lou==1)
                            <input type="radio" name="is_lou" value="1" checked id="yes"/>
                            <label for="yes">是</label>
                            <input type="radio" name="is_lou" value="0" id="no"/>
                            <label for="no">否</label>
                            @else
                            <input type="radio" name="is_lou" value="1"  id="yes"/>
                            <label for="yes">是</label>
                            <input type="radio" name="is_lou" checked value="0" id="no"/>
                            <label for="no">否</label>
                            @endif
                            
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">分类页面标题：</td>
                        <td>
                            <input type="text" value="{{$data->title}}" name="title" class="textBox length-long"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">分类页面关键词：</td>
                        <td>
                            <input type="text" value="{{$data->keywords}}" name="keywords" class="textBox length-long"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">分类页面描述：</td>
                        <td>
                            <textarea class="textarea" name="description" value="{{$data->description}}"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right;"></td> 
                        <td><input type="submit" value="保存" onclick="edit({{$data->id}})" class="tdBtn"/></td>
                    </tr>
                </form>
            </table>
        </div>
    </body>
    <script> 
           function edit(id){  
                var form = $('#Category_Add').serialize();  //序列化内容
                str = decodeURIComponent(form,true); //将数据解码            
                $.post('/admin/goods_category/'+id,{"str":str,'_token':'{{csrf_token()}}',"_method":"put"},function(data){ 
                       if(data==1){
                           window.location.href="/admin/goods_category";
                       }else{
                           alert(data);
                       }
               })
           }
    </script>
</html>